package com.zx.controller;/**
 * Author:JasonZ
 * Data:2023/4/17
 */

import com.zx.model.dto.UserToken;
import com.zx.model.vo.UsernameAndPassword;
import com.zx.service.AuthorityService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @program: ecommerce-parent
 *
 * @description:
 *
 * @author: JasonZ
 *
 * @create: 2023-04-17 14:00
 **/

@RestController
@RequestMapping("/authority")
public class AuthorityController {

    @Resource
    private AuthorityService authorityService;

    @PostMapping("/login")
    public UserToken login(@RequestBody UsernameAndPassword usernameAndPassword) throws Exception {
        return authorityService.login(usernameAndPassword);
    }

    @PostMapping("/register")
    public UserToken register(@RequestBody UsernameAndPassword usernameAndPassword) throws Exception {
        return authorityService.register(usernameAndPassword);
    }

}
